package com.li.senbiao.serial.bean;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class ObjectSizeHelper {
	
	public static int getSize(Object object) {
        ByteArrayOutputStream bf = new ByteArrayOutputStream();
        try {
            ObjectOutputStream out = new ObjectOutputStream(bf);
            out.writeObject(object);
            out.flush();
            out.close();
            return bf.size();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return -1;
    }
	
}
